#coding:utf-8
import requests
import sys
import re

reload(sys)
sys.setdefaultencoding('utf-8')


def getSchool(xxcode, bkh):
    '''获取录取学校, xxcode是出生年月， bkh是学号'''
    url = 'http://zkcj.xyzsb.net/selectzhongxueluqu_1.asp'
    headers = {"Content-Type":"application/x-www-form-urlencoded"}
    data = {'xxcode': xxcode,'bkh': bkh}
    r = requests.get(url, data=data, headers=headers)
    msg = re.compile('''<font color='#000000'>([\s\S]*?)</font>''')
    school = msg.findall(r.text)
    try:
        schoolValue = '您的录取情况如下\n'+school[0] +": "+ school[3] + "\n" + school[1] +": "+ school[4] + "\n" + school[2] +": "+ school[5].split('&')[0]
    except Exception, e:
        schoolValue = '查询出错...'
    
    return schoolValue